﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace SiteParser.Core
{
	public class HtmlNavigator : HtmlNavigatorBase
	{
		#region Constructors

		public HtmlNavigator(string filePath) {
			if (string.IsNullOrEmpty(filePath)) {
				throw new ArgumentNullException("filePath");
			}
			if (!File.Exists(filePath)) {
				throw new FileNotFoundException(filePath);
			}

			baseReader = new StreamReader(filePath);
		}

		public HtmlNavigator(TextReader baseReader) {
			if (baseReader == null) {
				throw new ArgumentNullException("baseReader");
			}

			this.baseReader = baseReader;
		}


		#endregion Constructors

		#region Overriden methods

		public override IHtmlIterator Select(HtmlNavigationExpression htmlNavigationExpression) {
			IHtmlIterator iterator = HtmlIteratorFactory.CreateIterator(baseReader.ReadToEnd(), htmlNavigationExpression);
			return iterator;
		}

		#endregion
	}
}
